package com.handl.springcloud.amqp.producer;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.annotation.Poller;
import org.springframework.integration.core.MessageSource;
import org.springframework.messaging.support.GenericMessage;

import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Stream;

/**
 * Created by handl on 2017/11/12.
 *
 */
@EnableBinding(value = {SendToBinder.class})
public class SendToSender {
    @Bean
    @InboundChannelAdapter(value = SendToBinder.OUTPUT, poller = @Poller(fixedDelay = "3000"))
    public MessageSource<String> sendToTest() {
        return () -> new GenericMessage<>("{\"name\":\"datang\",\"age\":89}");
    }

    @StreamListener(SendToBinder.INPUT) // 监听input通道
    public void receiveFromInput(String car) {
        System.out.println(car);
    }

}
